import { getAgentList, addAgent, updateAgent, checkAgent, getAgentUserList, updateAgentState, refushAgent, downloadData } from '../../api/agent'
const agent = {
    namespaced: true,
    state: {

    },
    getters: {

    },
    mutations: {

    },
    actions: {
        GetAgentList({ state, commit, dispatch }, params) {
            return new Promise((resolve, reject) => {
                getAgentList(params).then(res => {
                    resolve(res)
                }).catch(err => {
                    reject(err)
                })
            })
        },
        AddAgent({ state, commit, dispatch }, data) {
            return new Promise((resolve, reject) => {
                addAgent(data).then(res => {
                    resolve(res)
                })
            })
        },
        UpdateAgent({ state, commit, dispatch }, data) {
            return new Promise((resolve, reject) => {
                updateAgent(data).then(res => {
                    resolve(res)
                })
            })
        },
        CheckAgent ({ state, commit, dispatch }, params) {
            return new Promise((resolve, reject) => {
                checkAgent(params).then(res => {
                resolve(res)
              }).catch(err => {
                reject(err)
              })
            })
          },
        GetAgentUserList({ state, commit, dispatch }, data) {
            return new Promise((resolve, reject) => {
                getAgentUserList(data).then(res => {
                    resolve(res)
                })
            })
        },
        UpdateAgentState({ state, commit, dispatch }, custId) {
            return new Promise((resolve, reject) => {
                updateAgentState(custId).then(res => {
                    resolve(res)
                })
            })
        },
        RefushAgent({ state, commit, dispatch }, params) {
            return new Promise((resolve, reject) => {
                refushAgent(params).then(res => {
                    resolve(res)
                })
            })
        },
        DownloadData({ state, commit, dispatch }, params) {
            return new Promise((resolve, reject) => {
                downloadData(params).then(res => {
                    resolve(res)
                })
            })
        }
        
    }
}

export default agent
